{"ast":null,"code":"import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import Title from\"./utils/Title\";import{Context}from\"./index\";import{observer}from\"mobx-react-lite\";import{Route,Routes,useNavigate}from\"react-router-dom\";import{Auth,Im,Profile,Contacts}from\"./pages\";import{browserRouteAuth,browserRouteContacts,browserRouteIm,browserRouteProfile}from\"./routes\";import{Button,Modal}from\"./components\";import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";import{Fragment as _Fragment}from\"react/jsx-runtime\";var App=function App(){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var navigate=useNavigate();var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),showModal=_React$useState2[0],setShowModal=_React$useState2[1];Title();React.useEffect(function(){if(localStorage.getItem(\"\".concat(process.env.REACT_APP_NAME_TOKEN))){store.checkAuth();}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);React.useEffect(function(){if(store.getAuth()&&store.getProfile().verified){navigate(browserRouteIm);store.getContactsFromAPI();}else if(store.getAuth()&&!store.getProfile().verified){}else{navigate(browserRouteAuth);}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[store.getAuth(),store.getProfile().verified]);React.useEffect(function(){if(store.getProfile()&&!store.getProfile().verified){setShowModal(true);}else{setShowModal(false);}},[store.profile]);if(store.getLoading()){return/*#__PURE__*/_jsx(\"section\",{className:\"global_loading\",children:/*#__PURE__*/_jsx(\"div\",{className:\"loading\"})});}return/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(Modal,{active:showModal,title:\"Пользователь не верифицирован!\",hasFunctionButtons:false,children:/*#__PURE__*/_jsxs(\"div\",{className:\"modal__children-verification\",children:[/*#__PURE__*/_jsx(\"div\",{children:\"\\u0412\\u0430\\u043C \\u043D\\u0435\\u043E\\u0431\\u0445\\u043E\\u0434\\u0438\\u043C\\u043E \\u043F\\u0440\\u043E\\u0439\\u0442\\u0438 \\u0432\\u0435\\u0440\\u0438\\u0444\\u0438\\u043A\\u0430\\u0446\\u0438\\u044E \\u043F\\u043E \\u043F\\u043E\\u0447\\u0442\\u0435, \\u0447\\u0442\\u043E\\u0431\\u044B \\u0438\\u0441\\u043F\\u043E\\u043B\\u044C\\u0437\\u043E\\u0432\\u0430\\u0442\\u044C \\u0444\\u0443\\u043D\\u043A\\u0446\\u0438\\u043E\\u043D\\u0430\\u043B \\u043F\\u0440\\u0438\\u043B\\u043E\\u0436\\u0435\\u043D\\u0438\\u044F.\"}),/*#__PURE__*/_jsx(Button,{text:\"Обновить\",fullWidth:false,customClassName:\"button-refresh\",callback:function callback(){store.getProfileFromAPI();}})]})}),/*#__PURE__*/_jsxs(Routes,{children:[/*#__PURE__*/_jsx(Route,{path:browserRouteAuth,element:/*#__PURE__*/_jsx(Auth,{})}),/*#__PURE__*/_jsx(Route,{path:browserRouteIm,element:/*#__PURE__*/_jsx(Im,{})}),/*#__PURE__*/_jsx(Route,{path:browserRouteProfile,element:/*#__PURE__*/_jsx(Profile,{})}),/*#__PURE__*/_jsx(Route,{path:browserRouteContacts,element:/*#__PURE__*/_jsx(Contacts,{})})]})]});};export default observer(App);","map":{"version":3,"names":["React","Title","Context","observer","Route","Routes","useNavigate","Auth","Im","Profile","Contacts","browserRouteAuth","browserRouteContacts","browserRouteIm","browserRouteProfile","Button","Modal","App","useContext","store","navigate","useState","showModal","setShowModal","useEffect","localStorage","getItem","process","env","REACT_APP_NAME_TOKEN","checkAuth","getAuth","getProfile","verified","getContactsFromAPI","profile","getLoading","getProfileFromAPI"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/App.tsx"],"sourcesContent":["import React, {FC} from 'react';\nimport Title from \"./utils/Title\";\nimport {Context} from \"./index\";\nimport {observer} from \"mobx-react-lite\";\nimport {Route, Routes, useNavigate} from \"react-router-dom\";\nimport {Auth, Im, Profile, Contacts} from \"./pages\";\nimport {browserRouteAuth, browserRouteContacts, browserRouteIm, browserRouteProfile} from \"./routes\";\nimport {Button, Modal} from \"./components\";\n\nconst App: FC = () => {\n    const {store} = React.useContext(Context);\n    const navigate = useNavigate();\n    const [showModal, setShowModal] = React.useState<boolean>(false);\n\n    Title();\n\n    React.useEffect( () => {\n        if (localStorage.getItem(`${process.env.REACT_APP_NAME_TOKEN}`)) {\n            store.checkAuth();\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, []);\n\n    React.useEffect( () => {\n        if (store.getAuth() && store.getProfile().verified) {\n            navigate(browserRouteIm);\n            store.getContactsFromAPI();\n        } else if (store.getAuth() && !store.getProfile().verified) {\n        } else {\n            navigate(browserRouteAuth);\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.getAuth(), store.getProfile().verified]);\n\n    React.useEffect(() => {\n        if (store.getProfile() && !store.getProfile().verified) {\n            setShowModal(true);\n        } else {\n            setShowModal(false);\n        }\n    }, [store.profile]);\n\n    if (store.getLoading()) {\n        return (\n            <section className='global_loading'>\n                <div className=\"loading\"></div>\n            </section>\n        )\n    }\n\n    return (\n        <>\n            <Modal\n                active={showModal}\n                title={\"Пользователь не верифицирован!\"}\n                hasFunctionButtons={false}\n            >\n                <div className='modal__children-verification'>\n                    <div>Вам необходимо пройти верификацию по почте, чтобы использовать функционал приложения.</div>\n                    <Button\n                        text={\"Обновить\"}\n                        fullWidth={false}\n                        customClassName='button-refresh'\n                        callback={\n                            () => {store.getProfileFromAPI();}\n                        }\n                    />\n                </div>\n            </Modal>\n            <Routes>\n                <Route path={browserRouteAuth} element={<Auth/>} />\n                <Route path={browserRouteIm} element={<Im/>} />\n                <Route path={browserRouteProfile} element={<Profile/>} />\n                <Route path={browserRouteContacts} element={<Contacts/>} />\n            </Routes>\n        </>\n    );\n}\n\nexport default observer(App);\n"],"mappings":"8IAAA,MAAOA,MAAK,KAAY,OAAO,CAC/B,MAAOC,MAAK,KAAM,eAAe,CACjC,OAAQC,OAAO,KAAO,SAA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